package com.zhu.edu.service.impl;

import com.zhu.edu.entity.Term;
import com.zhu.edu.mapper.TermMapper;
import com.zhu.edu.service.TermService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author zjc
 * @since 2021-12-21
 */
@Service
public class TermServiceImpl extends ServiceImpl<TermMapper, Term> implements TermService {
    @Autowired
    TermMapper termMapper;

    @Override
    public void setThisTerm(Integer termId) {

        List<Term> terms = termMapper.selectList(null);
        for (Term term : terms) {
            term.setTermStatus(0);
            termMapper.updateById(term);
        }
        Term term = termMapper.selectById(termId);
        term.setTermStatus(1);
        termMapper.updateById(term);
    }

    @Override
    public List<Term> getAllTerm() {

        return termMapper.getAllTerm();

    }
}
